<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录 - {{$site->title}}</title>
    <link rel="stylesheet" type="text/css" href="/static/admin/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/admin/css/style.css">
    <link rel="stylesheet" type="text/css" href="/static/admin/css/login.css">
    <link rel="apple-touch-icon-precomposed" href="/static/admin/images/icon/icon.png">
    <link rel="shortcut icon" href="/static/admin/images/icon/favicon.ico">
    <script src="/static/admin/js/jquery-2.1.4.min.js"></script>
    <!--[if gte IE 9]>
    <script src="/static/admin/js/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/static/admin/js/html5shiv.min.js" type="text/javascript"></script>
    <script src="/static/admin/js/respond.min.js" type="text/javascript"></script>
    <script src="/static/admin/js/selectivizr-min.js" type="text/javascript"></script>
    <![endif]-->
    <!--[if lt IE 9]>
    <script>window.location.href='upgrade-browser.html';</script>
    <![endif]-->
</head>

<body class="user-select">
<div class="container">
    <div class="siteIcon"><img src="/static/admin/images/icon/icon.png" alt="" data-toggle="tooltip" data-placement="top" title="欢迎使用异清轩博客管理系统" draggable="false" /></div>
    <form action="" method="post" autocomplete="off" id="form_login" class="form-signin">
        <h2 class="form-signin-heading">管理员登录</h2>
        <label for="userName" class="sr-only">用户名</label>
        <input type="text" id="userName" name="username" class="form-control" placeholder="请输入用户名" required autofocus autocomplete="off" maxlength="10">
        <label for="userPwd" class="sr-only">密码</label>
        <input type="password" id="userPwd" name="password" class="form-control" placeholder="请输入密码" required autocomplete="off" maxlength="18">
        {{ csrf_field() }}
        <button class="btn btn-lg btn-primary btn-block" type="submit" id="form_submit">登录</button>
    </form>
    <div class="footer">
        <p><a href="{{route('index')}}" data-toggle="tooltip" data-placement="left" title="不知道自己在哪?">回到首页</a></p>
    </div>
</div>
<script src="/static/admin/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $(function(){
        let username = $('#userName');
        username.focus(function(){
            $(this).attr('placeholder','');
        });
        username.blur(function(){
            $(this).attr('placeholder','请输入用户名');
        });
        let password = $('#userPwd');
        password.focus(function(){
            $(this).attr('placeholder','');
        });
        password.blur(function(){
            $(this).attr('placeholder','请输入密码');
        });
        $('#form_submit').click(function(){
            if($('#userName').val() === ''){
                $(this).text('用户名不能为空');
            }else if($('#userPwd').val() === ''){
                $(this).text('密码不能为空');
            }else{
                $('#form_login').attr('autocomplete', 'off').submit(function(){
                    $.post("{{route('admin.loginInto')}}", $(this).serialize(), function(result){
                        $('#form_submit').text(result['message']);
                        if(result['status'] == 1000){
                            window.location.href = "{{route('admin')}}";
                        }
                    });
                    return false;
                });
            }
        });
    });
</script>
</body>
</html>
